<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <link rel="stylesheet" type="text/css" href="form.css" />
    <script type="text/javascript" src="JS/jquery.min.js"></script>
    <script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
    <script>
        $(function () {
            var match,
	        pl = /\+/g, // Regex for replacing addition symbol with a space
	        search = /([^&=]+)=?([^&]*)/g,
	        decode = function (s) {
	            return decodeURIComponent(s.replace(pl, " "));
	        },
	        query = window.location.search.substring(1);

            var urlParams = {};
            while (match = search.exec(query))
                urlParams[decode(match[1])] = decode(match[2]);

            window.fileName = urlParams["fileName"];
            window.folderName = urlParams["folderName"];
            window.assignmentId = urlParams["assignmentId"];
            window.turkSubmitTo = urlParams["turkSubmitTo"];
            function sendForm(e) {
                e.preventDefault();

                var fileName = window.fileName;
                var folderName = window.folderName;
                var headerData = {
                    file: fileName,
                    folder: folderName,
                    v01_gameStrategyDesc: $('#v01_gameStrategyDesc').val(),
                    v02_tendToSaveScore: $('input:radio[name=v02_tendToSaveScore]:checked').val(),
                    v03_fixIsBurden: $('input:radio[name=v03_fixIsBurden]:checked').val(),
                    v04_procrastinate: $('input:radio[name=v04_procrastinate]:checked').val(),
                    v05_knowRiskOfNotDoMntnce: $('input:radio[name=v05_knowRiskOfNotDoMntnce]:checked').val(),
                    v06_oldProductMntnce: $('input:radio[name=v06_oldProductMntnce]:checked').val(),
                    v07_readProspectForTimeMntnce: $('input:radio[name=v07_readProspectForTimeMntnce]:checked').val(),
                    v08_trustDiagnose: $('input:radio[name=v08_trustDiagnose]:checked').val(),
                    v09_scheduleAlertYourself: $('input:radio[name=v09_scheduleAlertYourself]:checked').val(),
                    v10_getAlertsAdvance: $('input:radio[name=v10_getAlertsAdvance]:checked').val(),
                    v11_turnOffAutoAlerts: $('input:radio[name=v11_turnOffAutoAlerts]:checked').val(),
                    v12_riskProneOrAverse: $('input:radio[name=v12_riskProneOrAverse]:checked').val(),
                    v13_usefulTool_Phone: $('input:radio[name=v13_usefulTool_Phone]:checked').val(),
                    v14_usefulTool_Email: $('input:radio[name=v14_usefulTool_Email]:checked').val(),
                    v15_usefulTool_Text_Message: $('input:radio[name=v15_usefulTool_Text_Message]:checked').val(),
                    v16_alertAreImportents: $('input:radio[name=v16_alertAreImportents]:checked').val(),
                    v17_careAboutMissedCalls: $('input:radio[name=v17_careAboutMissedCalls]:checked').val(),
                    v18_takeAlertsSeriously: $('input:radio[name=v18_takeAlertsSeriously]:checked').val(),
                    v19_differentMethosToContact: $('input:radio[name=v19_differentMethosToContact]:checked').val(),
                    v20_specificTimeToGetAlerts: $('input:radio[name=v20_specificTimeToGetAlerts]:checked').val(),
                    v21_callBackMissedCalls: $('input:radio[name=v21_callBackMissedCalls]:checked').val(),
                    v22_freeText: $('#v22_freeText').val()
                };

                $.ajax({
                    type: "POST",

                    url: "../MGGameService.svc/lastData/",
                    data: JSON.stringify(headerData),
                    success: function () {
                        window.location = "thank.html?folderName=" + folderName + "&fileName=" + fileName + "&turkSubmitTo=" + window.turkSubmitTo + "&assignmentId=" + window.assignmentId;
                    },
                    dataType: 'json'
                });

            }

            var target = $('#target');
            target.validator({
                position: "bottom center",
                onSuccess: sendForm,
               showErrors: function(errorMap, errorList) {
          if (submitted) {
              var summary = "";
              jQuery.each(errorList, function() {
              summary += "<li><label for='"+ this.element.name;
              summery += "' class='formError'>" + this.message + "</label></li>"; });
              jQuery("#errorMessageHeader").show();
              jQuery("#errorMessageHeader").children().after().html(summary);
              submitted = false;
          }
          this.defaultShowErrors();
      },      
            });

        });

    </script>
</head>
<body>
    <div id="form" class="lastForm">
    <p>We want to test your attitude to maintenance and alerts management.</p>
    <p>You must answer ALL questions and submit the HIT before we will pay you.</p>
    
        <form id="target">
        <div style="overflow: auto">
        	<h1>Game</h1>
        	 <p>
			                <label>
			                    Write a few sentences about your strategy throughout the game.<br />

			                </label>

			                <textarea rows="3" cols="50" id="v01_gameStrategyDesc" required></textarea>
			</p>
			<p>
			                <label>
			                    Did you tend to increase your score or to save time during the game? </label>
			                <br />
			                <input type="radio" name="v02_tendToSaveScore" value="Yes">Save score
			                <input type="radio" name="v02_tendToSaveScore" value="No">Save time
            </p>
                     <p>
			                <label>
			                    Would you define yourself as a risk-prone (many risks) or a risk-averse (few risks)
			                    person?
			                </label>
			                <br />
			                Many
			                <input type="radio" name="v12_riskProneOrAverse" value="1">
			                <input type="radio" name="v12_riskProneOrAverse" value="2">
			                <input type="radio" name="v12_riskProneOrAverse" value="3">
			                <input type="radio" name="v12_riskProneOrAverse" value="4">
			                <input type="radio" name="v12_riskProneOrAverse" value="5">
			                <input type="radio" name="v12_riskProneOrAverse" value="6">
			                Few
            </p>
            <h1> Maintenance </h1>
            <p>
            Consider an appliance that requires maintenance (e.g. Heating System), and relate to it in the following questions:
            </p>
            <p>
                <label>
                    Do you believe that fixing problems by yourself is a burden?</label>
                <br />
                <input type="radio" name="v03_fixIsBurden" value="Yes">Yes
                <input type="radio" name="v03_fixIsBurden" value="No">No
            </p>
            <p>
			                <label>
			                    Do you tend to procrastinate when you need to do maintenance?
			                </label>
			                <br />
			                No
			                <input type="radio" name="v04_procrastinate" value="1">
			                <input type="radio" name="v04_procrastinate" value="2">
			                <input type="radio" name="v04_procrastinate" value="3">
			                <input type="radio" name="v04_procrastinate" value="4">
			                <input type="radio" name="v04_procrastinate" value="5">
			                <input type="radio" name="v04_procrastinate" value="6">
			                Yes
            </p>
             <p>
			                <label>
			                    Do you need to know the risks of not doing maintenance before you decide to take
			                    preventive/regular maintenance actions?</label>
			                <br />
			                Never
			                <input type="radio" name="v05_knowRiskOfNotDoMntnce" value="1">
			                <input type="radio" name="v05_knowRiskOfNotDoMntnce" value="2">
			                <input type="radio" name="v05_knowRiskOfNotDoMntnce" value="3">
			                <input type="radio" name="v05_knowRiskOfNotDoMntnce" value="4">
			                <input type="radio" name="v05_knowRiskOfNotDoMntnce" value="5">
			                <input type="radio" name="v05_knowRiskOfNotDoMntnce" value="6">
			                Always
            </p>
            <p>
			                <label>
			                    Do you believe that if a product is too old then there is no point in maintaining
			                    it?</label>
			                <br />
			                No
			                <input type="radio" name="v06_oldProductMntnce" value="1">
			                <input type="radio" name="v06_oldProductMntnce" value="2">
			                <input type="radio" name="v06_oldProductMntnce" value="3">
			                <input type="radio" name="v06_oldProductMntnce" value="4">
			                <input type="radio" name="v06_oldProductMntnce" value="5">
			                <input type="radio" name="v06_oldProductMntnce" value="6">
			                Yes
            </p>
             <p>
			                <label>
			                    Do you read an appliance prospect to decide when to take maintenance actions?
			                </label>
			                <br />
			                No
			                <input type="radio" name="v07_readProspectForTimeMntnce" value="1">
			                <input type="radio" name="v07_readProspectForTimeMntnce" value="2">
			                <input type="radio" name="v07_readProspectForTimeMntnce" value="3">
			                <input type="radio" name="v07_readProspectForTimeMntnce" value="4">
			                <input type="radio" name="v07_readProspectForTimeMntnce" value="5">
			                <input type="radio" name="v07_readProspectForTimeMntnce" value="6">
			                Yes
            </p>
             <p>
			                <label>
			                    Do you trust a source that has already diagnosed a problem to you?</label>
			                <br />
			                No
			                <input type="radio" name="v08_trustDiagnose" value="1">
			                <input type="radio" name="v08_trustDiagnose" value="2">
			                <input type="radio" name="v08_trustDiagnose" value="3">
			                <input type="radio" name="v08_trustDiagnose" value="4">
			                <input type="radio" name="v08_trustDiagnose" value="5">
			                <input type="radio" name="v08_trustDiagnose" value="6">
			                Yes
            </p>
            <h1> Alerts </h1>
            <p>
            	Consider any area of your life that involves performing tasks from time to time and for which you would like to receive alerts or reminders.
            </p>
            <p>
                <label>
                    Do you like to schedule the alerts by yourself?</label>
                <br/>
                <input type="radio" name="v09_scheduleAlertYourself" value="Yes">Yes
                <input type="radio" name="v09_scheduleAlertYourself" value="No">No
            </p>
            <p>
                <label>
                    Do you prefer to get alerts far in advance?</label>
                <br />
                <input type="radio" name="v10_getAlertsAdvance" value="Yes">Yes
                <input type="radio" name="v10_getAlertsAdvance" value="No">No
            </p>

            <p>
                <label>
                    Do you turn off automatic alerts?</label>
                <br />
                No
                <input type="radio" name="v11_turnOffAutoAlerts" value="1">
                <input type="radio" name="v11_turnOffAutoAlerts" value="2">
                <input type="radio" name="v11_turnOffAutoAlerts" value="3">
                <input type="radio" name="v11_turnOffAutoAlerts" value="4">
                <input type="radio" name="v11_turnOffAutoAlerts" value="5">
                <input type="radio" name="v11_turnOffAutoAlerts" value="6">
                Yes
            </p>

            <p>
                <label>
                    Consider an alert that you receive from your bank or an alert for renewing your
                    insurance. How are these tools useful to you?</label>
                <table border="1">
                    <tbody>
                        <tr>
                            <td>
                            </td>
                            <td>
                                Not Useful
                            </td>
                            <td align="center">
                                1
                            </td>
                            <td align="center">
                                2
                            </td>
                            <td align="center">
                                3
                            </td>
                            <td align="center">
                                4
                            </td>
                            <td align="center">
                                5
                            </td>
                            <td align="center">
                                6
                            </td>
                            <td>
                                Very Useful
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span class="answertext">Phone</span>
                            </td>
                            <td align="center">
                                <span class="answertext">-</span>
                            </td>
                            <td valign="center">
                                <input type="radio" value="1" name="v13_usefulTool_Phone">
                            </td>
                            <td valign="center">
                                <input type="radio" value="2" name="v13_usefulTool_Phone">
                            </td>
                            <td valign="center">
                                <input type="radio" value="3" name="v13_usefulTool_Phone">
                            </td>
                            <td valign="center">
                                <input type="radio" value="4" name="v13_usefulTool_Phone">
                            </td>
                            <td valign="center">
                                <input type="radio" value="5" name="v13_usefulTool_Phone">
                            </td>
                            <td valign="center">
                                <input type="radio" value="6" name="v13_usefulTool_Phone">
                            </td>
                            <td align="center">
                                <span class="answertext">+</span>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span class="answertext">Email</span>
                            </td>
                            <td align="center">
                                <span class="answertext">-</span>
                            </td>
                            <td valign="center">
                                <input type="radio" value="1" name="v14_usefulTool_Email">
                            </td>
                            <td valign="center">
                                <input type="radio" value="2" name="v14_usefulTool_Email">
                            </td>
                            <td valign="center">
                                <input type="radio" value="3" name="v14_usefulTool_Email">
                            </td>
                            <td valign="center">
                                <input type="radio" value="4" name="v14_usefulTool_Email">
                            </td>
                            <td valign="center">
                                <input type="radio" value="5" name="v14_usefulTool_Email">
                            </td>
                            <td valign="center">
                                <input type="radio" value="6" name="v14_usefulTool_Email">
                            </td>
                            <td align="center">
                                <span class="answertext">+</span>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span class="answertext">Text Message</span>
                            </td>
                            <td align="center">
                                <span class="answertext">-</span>
                            </td>
                            <td valign="center">
                                <input type="radio" value="1" name="v15_usefulTool_Text_Message">
                            </td>
                            <td valign="center">
                                <input type="radio" value="2" name="v15_usefulTool_Text_Message">
                            </td>
                            <td valign="center">
                                <input type="radio" value="3" name="v15_usefulTool_Text_Message">
                            </td>
                            <td valign="center">
                                <input type="radio" value="4" name="v15_usefulTool_Text_Message">
                            </td>
                            <td valign="center">
                                <input type="radio" value="5" name="v15_usefulTool_Text_Message">
                            </td>
                            <td valign="center">
                                <input type="radio" value="6" name="v15_usefulTool_Text_Message">
                            </td>
                            <td align="center">
                                <span class="answertext">+</span>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </p>
            <p>
                <label>
                    Do you believe that alerts are important since they lead you to act?</label>
                <br />
                <input type="radio" name="v16_alertAreImportents" value="Yes">Yes
                <input type="radio" name="v16_alertAreImportents" value="No">No
            </p>
            <p>
                <label>
                    Do you care about missed calls?</label>
                <br />
                No
                <input type="radio" name="v17_careAboutMissedCalls" value="1">
                <input type="radio" name="v17_careAboutMissedCalls" value="2">
                <input type="radio" name="v17_careAboutMissedCalls" value="3">
                <input type="radio" name="v17_careAboutMissedCalls" value="4">
                <input type="radio" name="v17_careAboutMissedCalls" value="5">
                <input type="radio" name="v17_careAboutMissedCalls" value="6">
                Yes
            </p>
            <p>
                <label>
                    Do you take alerts seriously?</label>
                <br />
                <input type="radio" name="v18_takeAlertsSeriously" value="Yes">Yes
                <input type="radio" name="v18_takeAlertsSeriously" value="No">No
            </p>
            <p>
                <label>
                    Do you use different methods to contact different people?</label>
                <br />
                <input type="radio" name="v19_differentMethosToContact" value="Yes">Yes
                <input type="radio" name="v19_differentMethosToContact" value="No">No
            </p>
            <p>
                <label>
                    Are there specific times when you prefer to get alerts?</label>
                <input type="radio" name="v20_specificTimeToGetAlerts" value="Yes">Yes
                <input type="radio" name="v20_specificTimeToGetAlerts" value="No">No
            </p>
            <p>
                <label>
                    How immediately you call back missed calls or return messages?</label>
                <br />
                Immediately
                <input type="radio" name="v21_callBackMissedCalls" value="1">
                <input type="radio" name="v21_callBackMissedCalls" value="2">
                <input type="radio" name="v21_callBackMissedCalls" value="3">
                <input type="radio" name="v21_callBackMissedCalls" value="4">
                <input type="radio" name="v21_callBackMissedCalls" value="5">
                <input type="radio" name="v21_callBackMissedCalls" value="6">
                Sometime
            </p>			
            <p>
					<label>
						Please enter any comments.<br />
					</label>
					<textarea rows="3" cols="50" id="v22_freeText" required></textarea>
			</p>
        </div>
        <div id="errorMessageHeader"></div>
        <p>
            <input type="submit" value="Send" /></p>
        </form>
    </div>
</body>
</html>
